package com.runnable;

public  class MyRunnable implements Runnable {

	public  String name;
	public MyRunnable(String name) {
		this.name=name;
	}
	@Override
	public void run() {
		synchronized (this) { //class room

			for (int i = 0; i < 10; i++) {
                System.out.println(i);
				if(name.equals("hello")) {
                    System.out.println(Thread.currentThread().getName()+" is going to wait..");
					try {
						this.wait(); //going to wait state
						name="world";
						System.out.println(Thread.currentThread().getName()+"  is come out from wait..");
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}

			}
		}		
	}
}
